*SM-E23-Figure

set scheme stcolor
version 17

use ../Metadata/tess_analysisdata.dta, clear	

 * % hypotheses supported 
	tempvar temp
	cap drop total_hyp_true
	
	egen total_hyp_true=sum(hyp_true_insample), by(vendor_id)
	gen `temp'=  total_hyp_true/total_hyp_insample
	egen pctsupported= max(`temp'), by(vendor_id)
	
	sum pctsupported if hyp_num==1

 
cap frame change default
cap frame drop results
frame create results strL varname mean se ul ll str8 N color
	
	keep if hyp_num==1
	
	gen faculty = (title == 3 | title == 4 | title == 5)
	
	mean pctsupported if faculty == 1 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,1]
	local se = table[2,1]
	local ll = table[5,1]
	local ul = table[6,1]
	local N	 = table[7,1]+1		
	frame post results ("Faculty") (`mean') (`se') (`ll') (`ul') ("N=`N'") (1)

	mean pctsupported if faculty == 0 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,1]
	local se = table[2,1]
	local ll = table[5,1]
	local ul = table[6,1]
	local N	 = table[7,1]+1			
	frame post results ("Non-faculty") (`mean') (`se') (`ll') (`ul') ("N=`N'")	(1)

	gen multiauthor = numauthors > 1 if numauthors < .
		
	mean pctsupported if multiauthor == 0 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,1]
	local se = table[2,1]
	local ll = table[5,1]
	local ul = table[6,1]
	local N	 = table[7,1]+1			
	frame post results ("Sole-authored") (`mean') (`se') (`ll') (`ul') ("N=`N'") (2)

	mean pctsupported if multiauthor == 1 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,1]
	local se = table[2,1]
	local ll = table[5,1]
	local ul = table[6,1]
	local N	 = table[7,1]+1			
	frame post results ("Co-authored") (`mean') (`se') (`ll') (`ul') ("N=`N'")	(2)

	cap drop polisci
	gen polisci = (discipline == 5)
	
	mean pctsupported if polisci == 1 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,1]
	local se = table[2,1]
	local ll = table[5,1]
	local ul = table[6,1]
	local N	 = table[7,1]+1			
	frame post results (`""Political" "science""') (`mean') (`se') (`ll') (`ul') ("N=`N'")	(3)

	mean pctsupported if polisci == 0 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,1]
	local se = table[2,1]
	local ll = table[5,1]
	local ul = table[6,1]
	local N	 = table[7,1]+1			
	frame post results (`""Not political" "science""') (`mean') (`se') (`ll') (`ul') ("N=`N'")	(3)

	
	frame results {

		cap drop xlabel
		gen xlabel=_n
		labmask xlabel, values(varname)

		cap drop mlabel
		gen mlabel=0.05
		
		graph twoway ///
		(bar mean xlabel , barw(0.8) colorvar(color) colorlist(stc1%50 stc2%50 stc3%50)  colordiscrete lc(none)) ///
		(rcap ll ul xlabel ,lc(gs7)) ///	
		(scatter mlabel xlabel , ///
msym(none) mlab(N) mlabpos(0) mlabcolor(black) mlabsize(2.4) mlabangle(hor)) ///
		, ///		
			ytitle("Prop. (positive results)", size(small) margin(r=2)) ///
			xlabel(, labsize(small) angle(hor) valuelabel nogrid) ///
			xtitle(" ", margin(b=2)) ///
			ylabel(0(0.2)1, labsize(small) gmax gmin nogrid) ///
			graphregion(color(white)) ///
			scheme(stcolor) ///
			legend(off) clegend(off) ///
			xsize(8) ysize(5.5) ///
			name(inv_explevel, replace)
	
	}
 


		
graph export "../Results/SM-E23-Figure-InvestigatorCharacteristics.pdf", replace		
	